package com.uzhie.jt808;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import org.apache.log4j.Logger;

import java.net.SocketAddress;

/**
 * Created by TangFei on 2018/7/25.
 * 808协议响应处理器
 */
@ChannelHandler.Sharable
public class JT808ChannelOutHandler extends ChannelOutboundHandlerAdapter {

    private Logger logger = Logger.getLogger(this.getClass());

    @Override
    public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception {
        super.bind(ctx, localAddress, promise);
        logger.trace("in JT808ChannelOutHandler method bind " + ctx);
    }

    @Override
    public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception {
        super.connect(ctx, remoteAddress, localAddress, promise);
        logger.trace("in JT808ChannelOutHandler method connect " + ctx);
    }

    @Override
    public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
        super.disconnect(ctx, promise);
        logger.trace("in JT808ChannelOutHandler method disconnect " + ctx);
    }

    @Override
    public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
        super.close(ctx, promise);
        logger.trace("in JT808ChannelOutHandler method close " + ctx);
    }

    @Override
    public void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
        super.deregister(ctx, promise);
        logger.trace("in JT808ChannelOutHandler method deregister " + ctx);
    }

    @Override
    public void read(ChannelHandlerContext ctx) throws Exception {
        super.read(ctx);
        logger.trace("in JT808ChannelOutHandler method read " + ctx);
    }

    @Override
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
        super.write(ctx, msg, promise);
        logger.trace("in JT808ChannelOutHandler method write " + ctx);
    }

    @Override
    public void flush(ChannelHandlerContext ctx) throws Exception {
        super.flush(ctx);
        logger.trace("in JT808ChannelOutHandler method flush " + ctx);
    }
}
